package com.xsf.pay.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xsf.pay.common.domain.BasePageParam;
import com.xsf.pay.common.domain.ResultData;
import com.xsf.pay.entity.dto.CommonDelDto;
import org.springframework.web.bind.annotation.PostMapping;
import com.xsf.pay.service.VirtualAccountService;
import com.xsf.pay.entity.VirtualAccount;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource;

/**
 * 虚拟账户表
 *
 * @author makejava
 * @since 2025-05-12 15:09:58
 */
@RestController
@RequestMapping("virtualAccount")
public class VirtualAccountController {

    @Resource
    private VirtualAccountService virtualAccountService;
    
    /**
     * 分页查询
     * @return 返回数据
     */
    @PostMapping("/page")
    public ResultData<Page<VirtualAccount>> page(@RequestBody BasePageParam<VirtualAccount> basePageParam) {
        return ResultData.success(virtualAccountService.page(basePageParam.getPage()));
    }
    
    /**
     * 新增
     * @return 操作是否成功
     */
    @PostMapping("/insert")
    public ResultData<Object> insert(@RequestBody VirtualAccount virtualAccount) {
        return ResultData.success(virtualAccountService.save(virtualAccount));
    }

    /**
     * 修改
     * @return 操作是否成功
     */
    @PostMapping("/update")
    public ResultData<Object> update(@RequestBody VirtualAccount virtualAccount) {
        return ResultData.success(virtualAccountService.updateById(virtualAccount));
    }

    /**
     * 删除
     * @return 操作是否成功
     */
    @PostMapping("/del")
    public ResultData<Object> del(@RequestBody CommonDelDto commonDelDto) {
        return ResultData.success(virtualAccountService.removeById(commonDelDto.getId()));
    }
}

